package com.yuwj.chinaa.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yuwj.chinaa.R;
import com.yuwj.chinaa.base.BaseActivity;
import com.yuwj.chinaa.entity.EntityMiner;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 首页购买矿机成功界面
 */
public class HomeBuyMachineSuccessActivity extends BaseActivity {


    EntityMiner entityMiner;
    String count;
    String totalCoast;
    String orderId;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.tv_miner_buy_success_tip)
    TextView tvMinerBuySuccessTip;
    @BindView(R.id.tv_count)
    TextView tvCount;
    @BindView(R.id.tv_order_id)
    TextView tvOrderId;
    @BindView(R.id.tv_total_cost)
    TextView tvTotalCost;
    @BindView(R.id.ll_see_machine)
    LinearLayout llSeeMachine;

    public static Intent createIntent(Context context, EntityMiner entityMiner, String count, String totalCoast, String orderId) {
        Intent intent = new Intent(context, HomeBuyMachineSuccessActivity.class);
        intent.putExtra("entityMiner",entityMiner);
        intent.putExtra("count",count);
        intent.putExtra("totalCoast",totalCoast);
        intent.putExtra("orderId",orderId);
        return intent;
    }

    @Override
    public int setCustomContentViewResourceId() {
        return R.layout.activity_buy_ore_machine_success;
    }

    @Override
    public void initParam() {
        Intent intent = getIntent();
        entityMiner = (EntityMiner) intent.getSerializableExtra("entityMiner");
        count = intent.getStringExtra("count");
        totalCoast = intent.getStringExtra("totalCoast");
        orderId = intent.getStringExtra("orderId");
    }

    @Override
    public void initView() {
        initActionBar(toolbar, tvTitle, "购买成功");
        tvMinerBuySuccessTip.setText(entityMiner.getName() + " 购买成功!");
        tvTotalCost.setText(totalCoast + "");
        tvCount.setText(count + "台");
        tvOrderId.setText(orderId + "");
    }

    @Override
    public void initOperator() {

    }

    @OnClick({R.id.ll_see_machine})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_see_machine:
                startActivity(MyComputeCodeActivity.createIntent(context));
                finish();
                break;
        }
    }
}
